package tencent;

import java.util.Scanner;

public class Main {
     int maxPower = 0;

    public  void getMin(int[] members, int n, int path, int curPower, int powerCeil,int haveSelect){
        // 1-弹出
        if (path==n || haveSelect>n/2){
            maxPower = maxPower > curPower ? maxPower:curPower;
            return;
        }

        // 2.1 选
        if (curPower + members[path] <= powerCeil){
            getMin(members, n, path+1, curPower+members[path],powerCeil, haveSelect+1);
        }

        // 2.2 不选
        getMin(members,n,path+1,curPower,powerCeil, haveSelect);

    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int nextInt = sc.nextInt();
        int[] res = new int[nextInt*2];

        for (int i=0;i<nextInt;i++){
            Main main = new Main();
            main.maxPower = 0;
            int count = sc.nextInt();
            int[] param = new int[count];
            int tempAllPower = 0;
            for (int j=0;j<count;j++){
                param[j] = sc.nextInt();
                tempAllPower += param[j];
            }

            main.getMin(param,count,0,0,tempAllPower/2,0);
            res[i*2] = main.maxPower;
            res[i*2+1] = tempAllPower - main.maxPower;

        }

        for (int i=0;i<nextInt;i++){
            int min = res[i*2] <= res[i*2+1] ? res[i*2]: res[i*2+1];
            int max =  res[i*2] >= res[i*2+1] ? res[i*2]: res[i*2+1];
            System.out.print(res[i*2]);
            System.out.print(" ");
            System.out.print(res[i*2+1]);
            if (i!=nextInt-1){
                System.out.print("\n");
            }
        }
    }
}
